'''
Created on Mar 2, 2012

@author: Johnathon
'''
import unittest
import util
from LineValues import Zero, X, One, D, DNot

class Test(unittest.TestCase):


    
    def test_One_OR(self):
        for val in util.VALUES:
            self.assertTrue(One.OR(val) is One)
    
    def test_One_AND(self):
        for val in util.VALUES:
            self.assertTrue(One.AND(val) is val)
            
    def test_One_XOR(self):
        for val in util.VALUES:
            self.assertTrue(One.XOR(val) is val.NOT()) 
            
    def test_Zero_OR(self):
        for val in util.VALUES:
            self.assertTrue(Zero.OR(val) is val)
    
    def test_Zero_AND(self):
        for val in util.VALUES:
            self.assertTrue(Zero.AND(val) is Zero)
            
    def test_Zero_XOR(self):
        for val in util.VALUES:
            self.assertTrue(Zero.XOR(val) is val)
            
    def test_X_OR(self):
        for val in util.VALUES:
            if val is not One:
                self.assertTrue(X.OR(val) is X)
            else:
                self.assertTrue(X.OR(val) is One)
                
    def test_X_AND(self):
        for val in util.VALUES:
            if val is not Zero:
                self.assertTrue(X.AND(val) is X)
            else:
                self.assertTrue(X.AND(val) is Zero)
    
    def test_X_XOR(self):
        for val in util.VALUES:
            self.assertTrue(X.XOR(val) is X)
            
    def test_D_OR(self):
        self.assertTrue(D.OR(D) is D)
        self.assertTrue(D.OR(DNot) is One)

    def test_D_AND(self):
        self.assertTrue(D.AND(D) is D)
        self.assertTrue(D.AND(DNot) is Zero)
    
    def test_D_XOR(self):
        self.assertTrue(D.XOR(D) is Zero)
        self.assertTrue(D.XOR(DNot) is One)
    
    def test_DNot_OR(self):
        self.assertTrue(DNot.OR(D) is One)
        self.assertTrue(DNot.OR(DNot) is DNot)
        
    def test_DNot_AND(self):
        self.assertTrue(DNot.AND(D) is Zero)
        self.assertTrue(DNot.AND(DNot) is DNot)
        
    def test_DNot_XOR(self):
        self.assertTrue(DNot.XOR(D) is One)
        self.assertTrue(DNot.XOR(DNot) is Zero)
    
    def testXLineValue(self):
        for val in util.VALUES:
            if val is not Zero:
                self.assertTrue(X.AND(val) is X)
        

if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    unittest.main()